import os
import random


def 从文件路径中获取文件名(file_path: str) -> str:
    return os.path.splitext(os.path.basename(file_path))[0]

def 获取指定目录下的所有文件的绝对路径(path: str, recursion=True) -> list:
    if recursion:
        result = []
        for root, dirs, files in os.walk(path):
            for file in files:
                result.append(os.path.join(root, file))
        return result
    else:
        return [os.path.join(path, i) for i in os.listdir(path)]


def 判断list中的元素都一样(list_: list) -> bool:
    return all([list_[0] == i for i in list_[1:]])


class 随机抽取元素:
    def __init__(self, list_: list):
        self.list_ = list_
        self.choice_list = []

    def init_list(self):
        self.choice_list = self.list_.copy()

    def 随机抽取(self) -> list:
        if not self.choice_list:
            self.init_list()
        return self.choice_list.pop(random.randint(0, len(self.choice_list) - 1))


if __name__ == '__main__':
    print(判断list中的元素都一样([[1080000, 1920], [1080000, 1920]]))
